package com.newegg.datafeed.adserving.api;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.newegg.datafeed.adserving.response.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags="Demo")
@RestController
@RequestMapping("/api/demo")
public class DemoAPI extends BaseAPI{

	@ApiOperation(value="Demo1", consumes="application/json", produces="application/json")
    @RequestMapping(value="/demo1", method = RequestMethod.GET)
	@ResponseBody
    public Response<String> test1() throws Exception {
		return SUCCESS("Test");
    }

	@ApiOperation(value="Demo2", consumes="application/json", produces="application/json")
    @RequestMapping(value="/demo2", method = RequestMethod.GET)
	@ResponseBody
    public Response<Map<String, Object>> test2() throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("key1", "value1");
		map.put("key2", true);
		map.put("key3", new Date());
		map.put("key4", new HashMap<String, String>(){
			private static final long serialVersionUID = 8519667357102422203L;
			{
				put("map1", "value1");
				put("map2", "value2");
			}
		});
		map.put("key5", new ArrayList<String>(){
			private static final long serialVersionUID = 1957444424413134297L;
			{
				add("list1");
				add("list2");
				add("list3");
			}
		});
		return SUCCESS(map);
    }
}
